#include <cstring>
#include <wchar.h>
#include <iostream>

namespace CERT_FILE_PTR_DEREF_INDIRECT {

	namespace bad {
	
		typedef FILE file4;
		typedef file4 file3;
		typedef file3 file2;
		typedef file2 file;
		file* pf1;

#define FILE_ALIAS FILE
		FILE_ALIAS* pf2;

		typedef FILE* file_pointer;
		file_pointer pf3;

		typedef int* int_alias2;
		typedef int_alias2 int_alias1;
		typedef int_alias1 int_alias;
		int_alias pf4;

		void func5_memcpy_function(void)
		{
			memset((void*)pf1, '-', 0);
			memset((void*)pf2, '-', 0);
			wmemset((void*)pf3, '-', 0);
			memset((void*)pf4, '-', 0);

			memset((void*)pf1, '-', 9);
			memset((void*)pf2, '-', 9);
			memset((void*)pf4, '-', 9);
		}
	}
	

	namespace good {
		typedef FILE file4;
		typedef file4 file3;
		typedef file3 file2;
		typedef file2 file;
		file pf1;

#define FILE_ALIAS FILE
		FILE_ALIAS pf2;

		typedef FILE file_pointer;
		file_pointer pf3;

		typedef int* int_alias2;
		typedef int_alias2 int_alias1;
		typedef int_alias1 int_alias;
		int_alias pf4;

		void func5_memcpy_function(void)
		{
			memset((void*)pf1, '-', 0);
			memset((void*)pf2, '-', 0);
			wmemset((void*)pf3, '-', 0);
			memset((void*)pf4, '-', 0);
			memset((void*)pf4, '-', 9);
		}
	}
}